import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;


public class tetsHtmlParser {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		String str = "http://store.apple.com/us/product/TU243LL/A?mco=" +
		"MjQyMDQ1OA&s=newest'\"><A HREF=\"http://%77%77%77%2E%67%6F%6F%67%6C%65%2E%63%6F%6D\">XSS</A>&fnode=MTY1NDA4Mg";
		/*String str2 = "http://store.apple.com/us/product/TU243LL/A?mco=" + 
		"MjQyMDQ1OA&s=newest'\"><A%20HREF=\"http://www.google.com\">XSS</A>&fnode=MTY1NDA4Mg";*/
		String str2 = str.replaceAll("\\s", "%20");
		URL url,url2;
		try {
			//Send request
			url = new URL(str);
			url2 = new URL(str2);
			URLConnection conn = url.openConnection();
			URLConnection conn2 = url2.openConnection();			
			/*conn.addRequestProperty("User-Agent","Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/525.19 (KHTML, like Gecko) Chrome/1.0.154.48 Safari/525.19");
			conn.addRequestProperty("Accept-Encoding","gzip,deflate,bzip2,sdch");
			conn.addRequestProperty("Accept","text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*\/*;q=0.5");
			conn.addRequestProperty("Host","store.apple.com");
			conn.addRequestProperty("Connection","Keep-Alive");*/
	
			// Get the response
			BufferedReader rd = new BufferedReader(new InputStreamReader(conn2.getInputStream()));
			BufferedReader rd2 = new BufferedReader(new InputStreamReader(conn.getInputStream()));
			String line;
			while ((line = rd.readLine()) != null) {
				System.out.println(line);
			}
			rd.close();
		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}



	}

}
